package com.fw.ui.view.settings.usercontrol.merchantuser;

import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;

import com.fw.service.bean.EntryBean;
import com.fw.service.merchantuser.bean.MerchantUserBean;
import com.fw.ui.bao.MasterDataBAO;
import com.fw.ui.bao.MessageBAO;
import com.fw.ui.core.ViewDescription;
import com.fw.ui.util.UICommonUtils;
import com.fw.ui.util.VaadinApplicationObjectSupport;
import com.fw.ui.util.validator.StringLengthValidator;
import com.fw.ui.view.AbstractView;
import com.fw.ui.view.settings.usercontrol.merchantuser.event.CreateMerchantUserCancelButtonClickListener;
import com.fw.ui.view.settings.usercontrol.merchantuser.event.CreateMerchantUserClearButtonClickListener;
import com.fw.ui.view.settings.usercontrol.merchantuser.event.CreateMerchantUserMerchantOptionGroupValueChangeListener;
import com.fw.ui.view.settings.usercontrol.merchantuser.event.CreateMerchantUserMerchantValueChangeListener;
import com.fw.ui.view.settings.usercontrol.merchantuser.event.CreateMerchantUserSaveButtonClickListener;
import com.vaadin.data.validator.EmailValidator;
import com.vaadin.data.validator.RegexpValidator;
import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.OptionGroup;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

@org.springframework.stereotype.Component
@Scope(SCOPE_PROTOTYPE)
@ViewDescription(name = "settings-user-control-merchantuser-new", path = "/settings/user-control/merchantuser-new")
public class CreateMerchantUserView extends AbstractView {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Autowired
    protected transient VaadinApplicationObjectSupport app;

    @Autowired
    private MasterDataBAO masterDataBAO;
    @Autowired
    private MessageBAO messageBAO;

    /**
     * BEAN
     */
    private MerchantUserBean merchantUserBean = new MerchantUserBean();

    /**
     * EVENT
     */
    @Autowired
    private CreateMerchantUserClearButtonClickListener createMerchantUserClearButtonClickListener;
    @Autowired
    private CreateMerchantUserSaveButtonClickListener createMerchantUserSaveButtonClickListener;
    @Autowired
    private CreateMerchantUserCancelButtonClickListener createMerchantUserCancelButtonClickListener;
    @Autowired
    private CreateMerchantUserMerchantOptionGroupValueChangeListener createMerchantUserMerchantOptionGroupValueChangeListener;
    @Autowired
    private CreateMerchantUserMerchantValueChangeListener createMerchantUserMerchantValueChangeListener;

    /**
     * COMPONENT
     */
    private Panel createMerchantUserPanel = new Panel();

    private Label lblUsername = new Label("", ContentMode.HTML);
    private Label lblEmail = new Label("", ContentMode.HTML);
    private Label lblEmailFormatLeft = new Label("", ContentMode.HTML);
    private Label lblEmailFormatRight = new Label("", ContentMode.HTML);
    private Label lblName = new Label("", ContentMode.HTML);
    private Label lblGroup = new Label("", ContentMode.HTML);
    private Label lblServiceID = new Label("", ContentMode.HTML);

    private Label lblMerchantOrParentValidateMessage = new Label("", ContentMode.HTML);
    private Label lblUsernameValidateMessage = new Label("", ContentMode.HTML);
    private Label lblNameValidateMessage = new Label("", ContentMode.HTML);
    private Label lblEmailValidateMessage = new Label("", ContentMode.HTML);
    private Label lblGroupValidateMessage = new Label("", ContentMode.HTML);

    private HorizontalLayout row1Validate = new HorizontalLayout();
    private HorizontalLayout row2Validate = new HorizontalLayout();
    private HorizontalLayout row3Validate = new HorizontalLayout();
    private HorizontalLayout row4Validate = new HorizontalLayout();
    private HorizontalLayout row5Validate = new HorizontalLayout();

    private Button btnSave = new Button();
    private Button btnClear = new Button();
    private Button btnCancel = new Button();

    private OptionGroup ogMerchantOrParentId = new OptionGroup();
    private ComboBox cbbMerchant = new ComboBox();
    private ComboBox cbbService = new ComboBox();
    private ComboBox cbbParent = new ComboBox();
    private TextField txtUsername = new TextField();
    private TextField txtEmail = new TextField();
    private TextField txtName = new TextField();
    private ComboBox cbbGroup = new ComboBox();

    private String merchantOption;
    private String parentOption;

    @Override
    public void updateStrings() {

	this.lblUsername.setValue(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.label.username"));
	this.lblEmail.setValue(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.label.email"));
	this.lblEmailFormatRight.setValue(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.label.email.ex"));
	this.lblName.setValue(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.label.name"));
	this.lblGroup.setValue(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.label.group"));
	this.lblServiceID.setValue(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.label.serviceID"));
	this.cbbMerchant.setInputPrompt(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.inputprompt.merchant"));
	this.cbbParent.setInputPrompt(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.inputprompt.parent"));
	this.cbbService.setInputPrompt(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.inputprompt.service"));
	this.cbbGroup.setInputPrompt(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.inputprompt.group"));

	this.btnSave.setCaption(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.button.save"));
	this.btnClear.setCaption(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.button.clear"));
	this.btnCancel.setCaption(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.button.cancel"));

	this.createMerchantUserPanel.setCaption(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.title"));
    }

    @Override
    public void init() {
	this.setSizeFull();

	this.createMerchantUserPanel.setSizeFull();
	this.createMerchantUserPanel.setId("createMerchantUserPanel");

	this.ogMerchantOrParentId.setWidth("150px");
	this.lblUsername.setWidth("150px");
	this.lblEmail.setWidth("150px");
	this.lblGroup.setWidth("150px");
	this.lblName.setWidth("150px");
	this.lblEmailFormatLeft.setWidth("150px");
	this.lblEmailFormatRight.setWidth("200px");
	this.lblServiceID.setWidth("80px");
	this.cbbMerchant.setWidth("200px");
	this.cbbService.setWidth("200px");
	this.cbbParent.setWidth("200px");
	this.cbbGroup.setWidth("200px");
	this.txtUsername.setWidth("200px");
	this.txtEmail.setWidth("200px");
	this.txtName.setWidth("200px");

	this.lblMerchantOrParentValidateMessage.setId("lblMerchantOrParentValidateMessage" + UICommonUtils.INCLUDE_VALUE_COMPONENT_PREFIX);
	this.lblUsernameValidateMessage.setId("lblUsernameValidateMessage" + UICommonUtils.INCLUDE_VALUE_COMPONENT_PREFIX);
	this.lblEmailValidateMessage.setId("lblEmailValidateMessage" + UICommonUtils.INCLUDE_VALUE_COMPONENT_PREFIX);
	this.lblNameValidateMessage.setId("lblEmployeeNameValidateMessage" + UICommonUtils.INCLUDE_VALUE_COMPONENT_PREFIX);
	this.lblGroupValidateMessage.setId("lblGroupValidateMessage" + UICommonUtils.INCLUDE_VALUE_COMPONENT_PREFIX);

	this.row1Validate.setId("row1Validate" + UICommonUtils.INCLUDE_VISIBLE_COMPONENT_PREFIX);
	this.row2Validate.setId("row2Validate" + UICommonUtils.INCLUDE_VISIBLE_COMPONENT_PREFIX);
	this.row3Validate.setId("row6Validate" + UICommonUtils.INCLUDE_VISIBLE_COMPONENT_PREFIX);
	this.row4Validate.setId("row4Validate" + UICommonUtils.INCLUDE_VISIBLE_COMPONENT_PREFIX);
	this.row5Validate.setId("row5Validate" + UICommonUtils.INCLUDE_VISIBLE_COMPONENT_PREFIX);

	this.lblMerchantOrParentValidateMessage.setSizeUndefined();
	this.lblUsernameValidateMessage.setSizeUndefined();
	this.lblEmailValidateMessage.setSizeUndefined();
	this.lblNameValidateMessage.setSizeUndefined();
	this.lblGroupValidateMessage.setSizeUndefined();

	this.lblMerchantOrParentValidateMessage.addStyleName("validate-error");
	this.lblUsernameValidateMessage.addStyleName("validate-error");
	this.lblEmailValidateMessage.addStyleName("validate-error");
	this.lblNameValidateMessage.addStyleName("validate-error");
	this.lblGroupValidateMessage.addStyleName("validate-error");

	this.txtUsername.setMaxLength(50);
	this.txtEmail.setMaxLength(200);
	this.txtName.setMaxLength(150);

	this.cbbGroup.setNullSelectionAllowed(false);
	this.cbbGroup.setTextInputAllowed(false);

	VerticalLayout mainLayout = new VerticalLayout();
	mainLayout.setSizeFull();
	mainLayout.setSizeUndefined();
	mainLayout.setSpacing(true);
	mainLayout.setWidth("100%");

	this.createMerchantUserPanel.setContent(mainLayout);

	VerticalLayout formLayout = new VerticalLayout();
	formLayout.setId("formPanel");
	formLayout.setSizeUndefined();
	formLayout.setWidth("100%");
	formLayout.setSpacing(true);

	HorizontalLayout row1 = new HorizontalLayout();
	HorizontalLayout row2 = new HorizontalLayout();
	HorizontalLayout row3 = new HorizontalLayout();
	HorizontalLayout row3Sample = new HorizontalLayout();
	HorizontalLayout row4 = new HorizontalLayout();
	HorizontalLayout row5 = new HorizontalLayout();

	HorizontalLayout rowButton = new HorizontalLayout();

	row1.setSpacing(true);
	row2.setSpacing(true);
	row3.setSpacing(true);
	row3Sample.setSpacing(true);
	row4.setSpacing(true);
	row5.setSpacing(true);
	rowButton.setSpacing(true);
	row1Validate.setSpacing(true);
	row2Validate.setSpacing(true);
	row3Validate.setSpacing(true);
	row4Validate.setSpacing(true);
	row5Validate.setSpacing(true);

	row1.setSizeUndefined();
	row2.setSizeUndefined();
	row3.setSizeUndefined();
	row3Sample.setSizeUndefined();
	row4.setSizeUndefined();
	row5.setSizeUndefined();
	rowButton.setSizeUndefined();
	row1Validate.setSizeUndefined();
	row2Validate.setSizeUndefined();
	row3Validate.setSizeUndefined();
	row4Validate.setSizeUndefined();
	row5Validate.setSizeUndefined();

	row1.setWidth("600px");
	row2.setWidth("600px");
	row3.setWidth("600px");
	row3Sample.setWidth("600px");
	row4.setWidth("600px");
	row5.setWidth("600px");
	row1Validate.setWidth("100%");
	row2Validate.setWidth("100%");
	row3Validate.setWidth("100%");
	row4Validate.setWidth("100%");
	row5Validate.setWidth("100%");

	this.btnSave.addStyleName("button-blue");
	this.btnClear.addStyleName("button-green");
	this.btnCancel.addStyleName("button-red");
	this.btnSave.setDisableOnClick(true);
	this.btnClear.setDisableOnClick(true);
	this.btnCancel.setDisableOnClick(true);
	this.btnSave.setWidth("70px");
	this.btnClear.setWidth("70px");
	this.btnCancel.setWidth("70px");

	Label lblSepValidate1 = new Label("");
	Label lblSepValidate2 = new Label("");
	Label lblSepValidate3 = new Label("");
	Label lblSepValidate4 = new Label("");
	Label lblSepValidate5 = new Label("");

	lblSepValidate1.setWidth("150px");
	lblSepValidate2.setWidth("150px");
	lblSepValidate3.setWidth("150px");
	lblSepValidate4.setWidth("150px");
	lblSepValidate5.setWidth("150px");

	VerticalLayout verticalLayout = new VerticalLayout();
	verticalLayout.setSpacing(true);
	verticalLayout.setSizeUndefined();
	HorizontalLayout horizontalLayout = new HorizontalLayout();
	horizontalLayout.setSpacing(true);
	horizontalLayout.setSizeUndefined();
	horizontalLayout.addComponent(cbbMerchant);
	horizontalLayout.addComponent(lblServiceID);
	horizontalLayout.setComponentAlignment(lblServiceID, Alignment.BOTTOM_LEFT);
	horizontalLayout.addComponent(cbbService);
	verticalLayout.addComponent(horizontalLayout);
	verticalLayout.addComponent(cbbParent);
	row1.addComponent(ogMerchantOrParentId);
	row1.addComponent(verticalLayout);
	row1.setComponentAlignment(ogMerchantOrParentId, Alignment.MIDDLE_RIGHT);
	row1.setComponentAlignment(verticalLayout, Alignment.MIDDLE_LEFT);
	// row1.setExpandRatio(ogMerchantOrParentId, 2);
	// row1.setExpandRatio(verticalLayout, 3);

	row1Validate.addComponent(lblSepValidate1);
	row1Validate.addComponent(this.lblMerchantOrParentValidateMessage);
	row1Validate.setComponentAlignment(this.lblMerchantOrParentValidateMessage, Alignment.TOP_LEFT);

	row2.addComponent(lblUsername);
	row2.addComponent(txtUsername);
	row2.setComponentAlignment(lblUsername, Alignment.MIDDLE_RIGHT);
	row2.setComponentAlignment(txtUsername, Alignment.MIDDLE_LEFT);

	row2Validate.addComponent(lblSepValidate2);
	row2Validate.addComponent(this.lblUsernameValidateMessage);
	row2Validate.setComponentAlignment(this.lblUsernameValidateMessage, Alignment.TOP_LEFT);

	row3.addComponent(lblEmail);
	row3.addComponent(txtEmail);
	row3.setComponentAlignment(lblEmail, Alignment.MIDDLE_RIGHT);
	row3.setComponentAlignment(txtEmail, Alignment.MIDDLE_LEFT);

	row3Validate.addComponent(lblSepValidate3);
	row3Validate.addComponent(this.lblEmailValidateMessage);
	row3Validate.setComponentAlignment(this.lblEmailValidateMessage, Alignment.TOP_LEFT);

	row3Sample.addComponent(lblEmailFormatLeft);
	row3Sample.addComponent(lblEmailFormatRight);
	row3Sample.setComponentAlignment(lblEmailFormatLeft, Alignment.MIDDLE_RIGHT);
	row3Sample.setComponentAlignment(lblEmailFormatRight, Alignment.MIDDLE_LEFT);

	row4.addComponent(lblName);
	row4.addComponent(txtName);
	row4.setComponentAlignment(lblName, Alignment.MIDDLE_RIGHT);
	row4.setComponentAlignment(txtName, Alignment.MIDDLE_LEFT);

	row4Validate.addComponent(lblSepValidate4);
	row4Validate.addComponent(this.lblNameValidateMessage);
	row4Validate.setComponentAlignment(this.lblNameValidateMessage, Alignment.TOP_LEFT);

	row5.addComponent(lblGroup);
	row5.addComponent(cbbGroup);
	row5.setComponentAlignment(lblGroup, Alignment.MIDDLE_RIGHT);
	row5.setComponentAlignment(cbbGroup, Alignment.MIDDLE_LEFT);

	row5Validate.addComponent(lblSepValidate5);
	row5Validate.addComponent(this.lblGroupValidateMessage);
	row5Validate.setComponentAlignment(this.lblGroupValidateMessage, Alignment.TOP_LEFT);

	rowButton.addComponent(btnSave);
	rowButton.addComponent(btnClear);
	rowButton.addComponent(btnCancel);

	formLayout.addComponent(new HorizontalLayout());
	formLayout.addComponent(row1);
	formLayout.addComponent(row1Validate);
	formLayout.addComponent(row2);
	formLayout.addComponent(row2Validate);
	formLayout.addComponent(row3);
	formLayout.addComponent(row3Sample);
	formLayout.addComponent(row3Validate);
	formLayout.addComponent(row4);
	formLayout.addComponent(row4Validate);
	formLayout.addComponent(row5);
	formLayout.addComponent(row5Validate);
	formLayout.addComponent(new HorizontalLayout());
	formLayout.addComponent(rowButton);
	formLayout.addComponent(new HorizontalLayout());

	formLayout.setComponentAlignment(row1, Alignment.MIDDLE_CENTER);
	formLayout.setComponentAlignment(row2, Alignment.MIDDLE_CENTER);
	formLayout.setComponentAlignment(row3, Alignment.MIDDLE_CENTER);
	formLayout.setComponentAlignment(row3Sample, Alignment.MIDDLE_CENTER);
	formLayout.setComponentAlignment(row4, Alignment.MIDDLE_CENTER);
	formLayout.setComponentAlignment(row5, Alignment.MIDDLE_CENTER);
	formLayout.setComponentAlignment(rowButton, Alignment.MIDDLE_CENTER);
	formLayout.setComponentAlignment(row1Validate, Alignment.TOP_CENTER);
	formLayout.setComponentAlignment(row2Validate, Alignment.TOP_CENTER);
	formLayout.setComponentAlignment(row3Validate, Alignment.TOP_CENTER);
	formLayout.setComponentAlignment(row4Validate, Alignment.TOP_CENTER);
	formLayout.setComponentAlignment(row5Validate, Alignment.TOP_CENTER);

	row1Validate.setVisible(false);
	row2Validate.setVisible(false);
	row3Validate.setVisible(false);
	row4Validate.setVisible(false);
	row5Validate.setVisible(false);

	mainLayout.addComponent(formLayout);
	mainLayout.setComponentAlignment(formLayout, Alignment.MIDDLE_CENTER);

	this.addComponent(this.createMerchantUserPanel);
	this.setComponentAlignment(this.createMerchantUserPanel, Alignment.TOP_CENTER);

	this.merchantOption = this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.label.merchantID");
	this.parentOption = this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.label.parentID");
	this.ogMerchantOrParentId.addItem(this.merchantOption);
	this.ogMerchantOrParentId.addItem(this.parentOption);
	this.ogMerchantOrParentId.setNullSelectionAllowed(false);
	this.cbbMerchant.setReadOnly(false);
	this.cbbService.setReadOnly(true);
	this.cbbParent.setReadOnly(true);

	this.cbbMerchant.setFilteringMode(FilteringMode.STARTSWITH);
	this.cbbService.setFilteringMode(FilteringMode.STARTSWITH);
	this.cbbParent.setFilteringMode(FilteringMode.STARTSWITH);

	this.cbbMerchant.setNewItemsAllowed(false);
	this.cbbService.setNewItemsAllowed(false);
	this.cbbParent.setNewItemsAllowed(false);
    }

    @Override
    public void initListener() {
	this.createMerchantUserClearButtonClickListener.setBasedComponent(this);
	this.createMerchantUserSaveButtonClickListener.setBasedComponent(this);
	this.createMerchantUserCancelButtonClickListener.setBasedComponent(this);
	this.createMerchantUserMerchantOptionGroupValueChangeListener.setBasedComponent(this);
	this.createMerchantUserMerchantValueChangeListener.setBasedComponent(this);

	this.createMerchantUserClearButtonClickListener.setAutoEnabled(true);
	this.createMerchantUserSaveButtonClickListener.setAutoEnabled(true);
	this.createMerchantUserCancelButtonClickListener.setAutoEnabled(true);

	this.ogMerchantOrParentId.addValueChangeListener(createMerchantUserMerchantOptionGroupValueChangeListener);
	this.cbbMerchant.addValueChangeListener(createMerchantUserMerchantValueChangeListener);
	this.btnClear.addClickListener(this.createMerchantUserClearButtonClickListener);
	this.btnSave.addClickListener(this.createMerchantUserSaveButtonClickListener);
	this.btnCancel.addClickListener(this.createMerchantUserCancelButtonClickListener);

    }

    @Override
    public void initValidator() {
	this.ogMerchantOrParentId.setImmediate(true);

	this.txtUsername.setImmediate(true);
	this.txtUsername.setRequired(true);
	this.txtUsername.setRequiredError(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.message.username.mandatory"));
	RegexpValidator usernameRegexpValidator = new RegexpValidator("[a-zA-Z0-9]*", true,
		this.messageBAO
			.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.message.username.format"));
	StringLengthValidator uesrnameStringLengthValidator = new StringLengthValidator(
		this.messageBAO
			.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.message.username.length"),
		1, 50, false);
	this.txtUsername.addValidator(usernameRegexpValidator);
	this.txtUsername.addValidator(uesrnameStringLengthValidator);

	this.txtEmail.setImmediate(true);
	EmailValidator emailValidator = new EmailValidator(
		this.messageBAO.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.message.email.format"));
	this.txtEmail.addValidator(emailValidator);

	this.txtName.setImmediate(true);
	this.txtName.setRequired(true);
	this.txtName.setRequiredError(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.message.name.mandatory"));
	StringLengthValidator nameStringLengthValidator = new StringLengthValidator(
		this.messageBAO.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.message.name.length"),
		1, 150, true);
	this.txtName.addValidator(nameStringLengthValidator);

	this.cbbGroup.setImmediate(true);
	this.cbbGroup.setRequired(true);
	this.cbbGroup.setRequiredError(this.messageBAO
		.getMessage("com.fw.ui.view.settings.usercontrol.merchantuser.CreateMerchantUserView.message.group.mandatory"));
    }

    @Override
    public void initData() {
	try {
	    this.ogMerchantOrParentId.setValue(this.merchantOption);

	    List<EntryBean<Long, String>> merchantProfiles = masterDataBAO.selectAllMerchantUserMerchantProfile();
	    if (merchantProfiles != null) {
		for (EntryBean<Long, String> entry : merchantProfiles) {
		    this.cbbMerchant.addItem(entry.getKey());
		    this.cbbMerchant.setItemCaption(entry.getKey(), entry.getValue());
		}
	    }
	    List<EntryBean<Long, String>> parentMerchants = masterDataBAO.selectAllMerchantUserParentMerchant();
	    if (parentMerchants != null) {
		for (EntryBean<Long, String> entry : parentMerchants) {
		    this.cbbParent.addItem(entry.getKey());
		    this.cbbParent.setItemCaption(entry.getKey(), entry.getValue());
		}
	    }
	    List<EntryBean<Long, String>> roles = masterDataBAO.selectAllMerchantUserRole();
	    if (roles != null) {
		for (EntryBean<Long, String> entry : roles) {
		    this.cbbGroup.addItem(entry.getKey());
		    this.cbbGroup.setItemCaption(entry.getKey(), entry.getValue());
		}
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }

    public MasterDataBAO getMasterDataBAO() {
	return masterDataBAO;
    }

    public MessageBAO getMessageBAO() {
	return messageBAO;
    }

    public MerchantUserBean getMerchantUserBean() {
	return merchantUserBean;
    }

    public CreateMerchantUserClearButtonClickListener getCreateMerchantUserClearButtonClickListener() {
	return createMerchantUserClearButtonClickListener;
    }

    public CreateMerchantUserSaveButtonClickListener getCreateMerchantUserSaveButtonClickListener() {
	return createMerchantUserSaveButtonClickListener;
    }

    public CreateMerchantUserCancelButtonClickListener getCreateMerchantUserCancelButtonClickListener() {
	return createMerchantUserCancelButtonClickListener;
    }

    public Panel getCreateMerchantUserPanel() {
	return createMerchantUserPanel;
    }

    public Label getLblUsername() {
	return lblUsername;
    }

    public Label getLblEmail() {
	return lblEmail;
    }

    public Label getLblEmailFormat() {
	return lblEmailFormatLeft;
    }

    public Label getLblName() {
	return lblName;
    }

    public Label getLblGroup() {
	return lblGroup;
    }

    public Label getLblUsernameValidateMessage() {
	return lblUsernameValidateMessage;
    }

    public Label getLblNameValidateMessage() {
	return lblNameValidateMessage;
    }

    public Label getLblEmailValidateMessage() {
	return lblEmailValidateMessage;
    }

    public Label getLblGroupValidateMessage() {
	return lblGroupValidateMessage;
    }

    public HorizontalLayout getRow1Validate() {
	return row1Validate;
    }

    public HorizontalLayout getRow2Validate() {
	return row2Validate;
    }

    public HorizontalLayout getRow3Validate() {
	return row3Validate;
    }

    public HorizontalLayout getRow4Validate() {
	return row4Validate;
    }

    public HorizontalLayout getRow5Validate() {
	return row5Validate;
    }

    public Button getBtnSave() {
	return btnSave;
    }

    public Button getBtnClear() {
	return btnClear;
    }

    public Button getBtnCancel() {
	return btnCancel;
    }

    public OptionGroup getOgMerchantOrParentId() {
	return ogMerchantOrParentId;
    }

    public ComboBox getCbbMerchant() {
	return cbbMerchant;
    }

    public ComboBox getCbbParent() {
	return cbbParent;
    }

    public TextField getTxtUsername() {
	return txtUsername;
    }

    public TextField getTxtEmail() {
	return txtEmail;
    }

    public TextField getTxtName() {
	return txtName;
    }

    public ComboBox getCbbGroup() {
	return cbbGroup;
    }

    public String getMerchantOption() {
	return merchantOption;
    }

    public String getParentOption() {
	return parentOption;
    }

    public static long getSerialversionuid() {
	return serialVersionUID;
    }

    public Label getLblMerchantOrParentValidateMessage() {
	return lblMerchantOrParentValidateMessage;
    }

    public ComboBox getCbbService() {
	return cbbService;
    }

}
